package com.icehand.utils.encryption;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/**
 * Base64
 * Created by icehand on 2017/5/3.
 */
public class Base64Utils {
	/**
	 * BASE64解密
	 *
	 * @param key key
	 * @return byte[]
	 * @throws Exception ex
	 */
	@SuppressWarnings("restriction")
	public static byte[] decryptBASE64(String key) throws Exception {
		return (new BASE64Decoder()).decodeBuffer(key);
	}

	/**
	 * BASE64加密
	 * @param key key
	 * @return String
	 * @throws Exception ex
	 */
	@SuppressWarnings("restriction")
	public static String encryptBASE64(byte[] key) throws Exception {
		return (new BASE64Encoder()).encodeBuffer(key);
	}
}
